<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div></div>
<div></div>
<div></div>
<script>
    function $(ele) {
        var obj = document.querySelectorAll(ele);
        obj.each= function (callback) {
         return  each(this,callback);

        }
        return obj;
    }

    function each(arr, callback) {
       if(isArrayLike(arr)){
           for (var i = 0; i < arr.length; i++) {
               if(callback.call(arr[i],arr[i],i)===false)  break;
           }
       }else{
           for(var k in arr){
               if(callback.call(arr[k],arr[k],k)===false)  break;
           }
       }
        return arr;
    }
   function isArrayLike(obj){
       if(Object.prototype.toString.call(obj).slice(8,-1)==="Array"){
            return true;
       }
       var length = 'length' in obj && obj.length;
       return typeof (length === 'number' && length >= 0);
   }


</script>
</body>
</html>